﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.Localization;
using Volo.Abp.SettingManagement;
using Volo.Abp.Settings;

namespace Acme.BookStore.Settings
{
    //class BookStoreSettingsDataSeedContributor
    //{
    //}

    public class BookStoreSettingsDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        //private readonly IRepository<Book, Guid> _bookRepository;
        private readonly ISettingRepository _settingRepository;
        private readonly IGuidGenerator _guidGenerator;
        public BookStoreSettingsDataSeedContributor(
            //IRepository<Book, Guid> bookRepository,
            ISettingRepository settingRepository,
            IGuidGenerator guidGenerator)
        {
            //_bookRepository = bookRepository;
            _settingRepository = settingRepository;
            _guidGenerator = guidGenerator;
        }
        public async Task SeedAsync(DataSeedContext context)
        {
            //throw new NotImplementedException();
            //await _bookRepository.InsertAsync(new Book(_guidGenerator.Create())
            //{
            //    Name = "test book 1",
            //    Type = BookType.Adventure,
            //    PublishDate = new DateTime(2019, 10, 19),
            //    Price = 21
            //});
            //await _bookRepository.InsertAsync(new Book(_guidGenerator.Create())
            //{
            //    Name = "test book 2",
            //    Type = BookType.Adventure,
            //    PublishDate = new DateTime(2018, 12, 19),
            //    Price = 30
            //});

            await _settingRepository.InsertAsync(new Setting(
                _guidGenerator.Create(),
                LocalizationSettingNames.DefaultLanguage,
                "zh-Hans",
                GlobalSettingValueProvider.ProviderName
            ));

            await Task.CompletedTask;
        }
    }
}
